package com.example.teamtribe.common.send;

import android.os.Bundle;
import android.support.annotation.Nullable;

import com.example.teamtribe.common.Back;
import com.example.teamtribe.common.model.RelationModel;
import com.example.teamtribe.utils.Utility;

public class SendPresenter implements SendContract.Presenter {

    private SendContract.View view;

    public SendPresenter(SendContract.View view) {
        this.view = view;
    }

    @Override
    public void request(int id, String reason) {
        view.showProgress();
        RelationModel.getInstance().request(0, Utility.getToken(), id, reason, new Back() {
            @Override
            public void success(@Nullable Bundle bundle) {
                view.next();
            }

            @Override
            public void failure(String meg) {
                view.hideProgress();
                view.showToast(meg);
            }
        });
    }

    @Override
    public void response(int id, int result, String reason) {
        view.showProgress();
        RelationModel.getInstance().response(Utility.getToken(), id, result, reason, new Back() {
            @Override
            public void success(@Nullable Bundle bundle) {
                view.next();
            }

            @Override
            public void failure(String meg) {
                view.hideProgress();
                view.showToast(meg);
            }
        });
    }
}
